<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%-- <%@include file="/common/include.jsp"%> --%>
<script type="text/javascript" src="<%=request.getContextPath() %>/jsFile/common.js"></script>
<title>运价预警保存</title>

<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/show.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<link href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css' rel="stylesheet" type="text/css" />
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>
<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	
$(function(){
	$('#flightFrom').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	$('#flightTo').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	
})

 function saveConfig(){
	var flightFrom = $("#flightFrom").val();
	var flightTo = $("#flightTo").val();
	if(flightFrom=="" || flightTo =="" || flightFrom=="中文/拼音" || flightTo =="中文/拼音"){
		alert("航段不能为空");
		return;
	}
	var effectiveFrom = $("#effectiveFrom").val();
	var effectiveTo   = $("#effectiveTo").val();
	var s_date = new Date(effectiveFrom.replace(/-/g,"/"));
    var e_date = new Date(effectiveTo.replace(/-/g,"/"));
    
    var time1 = s_date.getTime();
	var time2 = e_date.getTime();
	if(time1>time2){
		alert("结束时间不能小于开始时间");
		return;
	}
	$.post('freightPriceAnalyseAlertConfigAction!saveFreightPriceAnalyseAlertConfig.action',
				$("#formSave").serialize(),
				function(data){
			if(data && data=="succes"){
				alert('保存成功');
				getBackInfo();
			}else{
				alert('保存失败'+data);
			}
			
	},'text');
}	


function getBackInfo(){
	$("#formSave").attr('action','freightPriceAnalyseAlertConfigAction!getAllFreightPriceAnalyseAlertConfig.action');
	$("#formSave").submit();
}
</script>
</head>


<body>

<form id="formSave" method="post">
<input type="hidden" id="id" name="id" value="${id}"/>
<TABLE cellSpacing=1 cellPadding=3 width="100%" border=0 class="tabg">
		<TR class="tr1">
			<TD colspan="10">运价预警配置</TD>
		</TR>
		<TR class="tab">
			<TD  height="100" style="text-align: left" class="td1" width="20%">说明：</TD>
			<TD>1、带红色 <font color="red">*</font>号的为必填项；<br/>
				2、用户在设置运价预警规则后，当运价差额比例符合某个条件时，系统自动发消息(邮件/短信)给制定该规则的用户；<br/>
				3、预警频率指在设定的预警有效期区间内，间隔多长时间进行一次差额比例，并发消息给提醒用户；单位为小时<br/>
				4、若用户预警方式中，没有勾选一项，则该条预警记录无效，将不会产生预警消息。<br/>
			</TD>
		</TR>
	<TR class="tab">
	<TD width="120" height="26" class="left" style="text-align:left">航空公司&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：
    </TD>
    <TD colspan="3">
       <select class="easyui-combobox" name="airCompany" style="width: 150px;" id="airCompany">
				<c:choose>
					<c:when test="${sourceList == null}">
					</c:when>
					<c:otherwise>
						<c:forEach var="item" items="${sourceList}">
							<option>${item.name}</option>
						</c:forEach>
					</c:otherwise>
				</c:choose>
		
		</select>
		<span style="color: #ff0000">*</span>
    </TD>
    </TR>
    <TR class="tab">
    <TD class="td1" style="text-align:left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;段：<font color="red">*</font>
    </TD>
    <TD>
      <span>从</span>
      <input type="text" style="width:100px" name="flightFrom" id="flightFrom" value="">
      <span>到</span>
      <input type="text" style="width:100px" name="flightTo" id="flightTo" value="">&nbsp;&nbsp;&nbsp;
    </TD>
  </TR>
  <TR class="tab">
  	<TD width="120" height="26" class="left" style="text-align:left">预警方式&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：
    </TD>
    <TD colspan="3">
      	<select class="easyui-combobox" name="alertWay" style="width: 150px;" id="alertWay">
				<option value="1" >邮件</option>
		</select>
		<span style="color: #ff0000">*</span>
    </TD>
    <TD width="120" height="26" class="left" style="text-align:left">未来天数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：
    </TD>
    <TD colspan="3">
      <input type="text" style="width:100px" name="futureDays" id="futureDays" value="">
      <span style="color: #ff0000">*</span>
    </TD>
    <!-- 
    <TD height="26" class="td1" style="text-align:left">差额比例：<font color="red">*</font></TD>
  	<TD><SPAN>比我航</SPAN>
  	  <select id="hv" name="hv">
  	    <option value="1" selected="selected">高</option>
  	    <option value="2">低</option>
  	  </select>
  	  <input type="text" style="width:30px" id="threshold" name="threshold" value="">%
  	</TD>
  	 -->
  </TR>
  <TR class="tab">
    <TD height="26" class="td1" style="text-align:left">预警有效期：<font color="red">*</font></TD>
    <TD>
      <span>从</span>
      <input type="text" style="width:150px" id="effectiveFrom" name="effectiveFrom" value="" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})">
      <span>到</span>
      <input type="text" style="width:150px" id="effectiveTo" name="effectiveTo" value="" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})">
	</TD>
  </TR>
  
  <TR>
  	<TD width="120" height="26" class="left" style="text-align:left">触发条件：
    </TD>
    <TD width="120" height="26" class="left" style="text-align:left">当天抓抓取到的航线未来各天的各最低价中，我航少于
    </TD>
    <TD colspan="3">
      <input type="text" style="width:100px" name="triggerCondition" id="triggerCondition" value="">天
      <span style="color: #ff0000">*</span>
    </TD>
    </TR>
    
  <TR align="center" class="tab">
  		<TD colspan="4">
  			 <input type="button"  id="Submit22" name="Submit22" value="保存规划" onclick="saveConfig()" style="width:80px;">
  			 <input type="reset" style="width: 40px;" value="重置"/>
  			 <input type="button" value="返回" onclick="getBackInfo()" style="width:80px;">
  		</TD>
  </TR>
	</table>
</form>
</body>